package com.xjie.net;

public class MyRunnable implements Runnable {
    private static int taskCount = 0;
    private final int taskId;

    public MyRunnable() {
        this.taskId = ++taskCount;
    }

    @Override
    public void run() {
        String threadName = Thread.currentThread().getName();
        System.out.println("任务 " + taskId + " 正在被线程 " + threadName + " 执行");
        try {
            Thread.sleep(6000); // 模拟任务执行时间
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        System.out.println("任务 " + taskId + " 在线程 " + threadName + " 中执行完毕");
    }
}
